<template>
  <el-container>
    <el-main>
      <div class="ht-pd-10">
        <el-button
          type="primary"
          class="ht-pl-pr-10"
          style="width:80px"
          @click="$router.push({ path: '/admin/sysdictype$create' })"
          size="mini"
          >新增</el-button
        >
      </div>
      <div class="dic-table">
        <el-table :data="sysdic_types" border stripe v-loading="loading">
          <el-table-column
            v-for="col in sysdictype_tableColums"
            :prop="col.field"
            :key="col.field"
            :label="col.label"
            :width="col.width"
          >
          </el-table-column>
          <el-table-column label="操作" width="180">
            <template slot-scope="scope">
              <el-link
                type="primary"
                class="ht-mr-10"
                @click="
                  $router.push({
                    path: `/admin/sysdictype$modify/${scope.row.id}`
                  })
                "
                >编辑</el-link
              >
              <el-link type="primary" @click="delDic(scope.row.id)"
                >删除</el-link
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-main>
  </el-container>
</template>

<script>
import qs from "qs";
export default {
  data() {
    return {
      loading: false,
      sysdictype_tableColums: [
        {
          label: "数据类型",
          field: "dicType"
        }
      ],
      sysdic_types: []
    };
  },
  methods: {
    getAllDictype() {
      this.$http.get("/sysdic/getAllDictype").then(res => {
        if (res.data.errorCode == "SUCCESS") {
          this.sysdic_types = res.data.returnData;
        } else {
          this.$message({
            type: "warning",
            message: res.data.errorMessage
          });
        }
      });
    },
    async delDic(id) {
      const res = await this.$http.post("/sysdic/delDicTypeById", {
        id: id
      });
      if (res.data.errorCode == "SUCCESS") {
        this.loadPageSysDic();
      } else {
        this.$message({
          type: "warning",
          message: res.data.errorMessage
        });
      }
    }
  },
  created() {
    this.getAllDictype();
  }
};
</script>

<style lang="scss"></style>
